//#include "cv.h"
//#include "opencv2\core.hpp"
//#include "opencv2\opencv.hpp"
//#include "opencv2\highgui.hpp"
//
//#include <iostream>
//
//
//int main() 
//{
//    cv::Mat img;
//	
//    img = cv::imread("test.tiff");
//
//	const int origRows = img.rows;
//	cv::Mat colVec = img.reshape(1, img.rows*img.cols); // change to a Nx3 column vector
//
//	cv::Mat colVecD, bestLabels, centers, clustered;
//	int attempts = 5;
//	int clusts = 3;
//	double eps = 0.001;
//	colVec.convertTo(colVecD, CV_32FC3, 1.0/255.0); // convert to floating point
//
//	double compactness = cv::kmeans(colVecD, clusts, bestLabels, 
//	      cv::TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, attempts, eps), 
//	      attempts, cv::KMEANS_PP_CENTERS, centers);
//	cv::Mat labelsImg = bestLabels.reshape(1, origRows); // single channel image of labels
//	labelsImg.convertTo(labelsImg, img.depth());
//	//cv::cvtColor(labelsImg, labelsImg, cv::COLOR_GRAY2BGR);
//	//cout << "Compactness = " << compactness << endl;
//
//	cv::Mat labels_normalized;
//	cv::normalize(labelsImg, labels_normalized, 0, 255, cv::NORM_MINMAX, CV_8UC1);
//	cv::imwrite("3clusters.png", labels_normalized);
//	
//	return EXIT_SUCCESS;
//}

// Include standard headers
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <memory>

// Include GLEW
#include <GL/glew.h>

// Include GLFW
#include <glfw3.h>
GLFWwindow* window;
//std::unique_ptr <GLFWwindow> window;

// Include GLM
#include <glm/glm.hpp>
using namespace glm;

int main( void )
{
	// Initialise GLFW
	if( !glfwInit() )
	{
		std::cerr << "Failed to initialize GLFW\n";
		return EXIT_FAILURE;
	}

	glfwWindowHint(GLFW_SAMPLES, 4); // 4x antialiasing
	glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); // OpenGL version
	glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
	glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); // no legacy OpenGL support

	// Open a window and create its OpenGL context
	window = glfwCreateWindow( 1024, 768, "Tutorial 01", NULL, NULL);
	//window = static_cast<std::unique_ptr <GLFWwindow>>(glfwCreateWindow( 1024, 768, "Tutorial 01", NULL, NULL));
	if( window == NULL )
	{
		std::cerr << "Failed to open GLFW window. If you have an Intel GPU, they are not 3.3 compatible. Try the 2.1 version of the tutorials.\n";
		glfwTerminate();
		return EXIT_FAILURE;
	}
	glfwMakeContextCurrent(window); // initialize GLEW

	// Initialize GLEW
	if (glewInit() != GLEW_OK) 
	{
		fprintf(stderr, "Failed to initialize GLEW\n");
		return EXIT_FAILURE;
	}

	// Ensure we can capture the escape key being pressed below
	glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE);

	// Dark blue background
	glClearColor(0.0f, 0.0f, 0.4f, 0.0f);

	do
	{
		// Draw nothing, see you in tutorial 2 !

		// Swap buffers
		glfwSwapBuffers(window);
		glfwPollEvents();

	} // Check if the ESC key was pressed or the window was closed
	while( glfwGetKey(window, GLFW_KEY_ESCAPE ) != GLFW_PRESS &&
		   glfwWindowShouldClose(window) == 0 );

	// Close OpenGL window and terminate GLFW
	glfwTerminate();

	return EXIT_SUCCESS;
}

